<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Http\model\Sms;

class AdminController extends BaseController
{
    /**
     * 司机信息接口
     * by 吉星
     */
    // 司机信息数据
    public function driver(Request $request){
        if($request){
            $where['driver_name'] = isset($request['driver_name']) ? $request['driver_name'] : false;
            $where['b.type'] = isset($request['type']) ? $request['type'] : false;
            $where['b.company_name'] = isset($request['company_name']) ? $request['company_name'] : false;
            $where['c.name'] = isset($request['convoy_name']) ? $request['convoy_name'] : false;
            $where['role'] = isset($request['role']) ? $request['role'] : false;
            $where['attendant'] = isset($request['attendant']) ? $request['attendant'] : false;
            $starttime = isset($request['starttime']) ? strtotime($request['starttime']) : false;
            $endtime = isset($request['endtime']) ? strtotime($request['endtime']) : false;
            $where['account_status'] = isset($request['account_status']) ? $request['account_status'] : false;
            // $where['a.is_delete'] = 1;
            // dump(1111);exit;
            $list = Db::table('driver as a')
                // ->where($where)
                ->where('a.is_delete','=','1')
                ->whereBetween('a.save_time',[$starttime,$endtime])
                ->join('branch as b','a.contract_company','=','b.id')
                ->join('convoy as c','a.convoy_id','=','c.id')
                ->select('*','a.id as aid')
                ->get()
                ->toArray();
        }else{
            // dump(2222);exit;
            $list = Db::table('driver as a')
                ->where('a.is_delete','=','1')
                ->join('branch as b','a.contract_company','=','b.id')
                ->join('convoy as c','a.convoy_id','=','c.id')
                ->select('*','a.id as aid')
                ->get()
                ->toArray();
        }
        $list = json_decode(json_encode($list),true);
        return $list;
            
    }
}
